##!/usr/bin/env python3
# -*- coding: utf-8 -*-

L = [x * x for x in range(1, 11)]
print(L)

G = (x * x for x in range(1, 11))
print(G)
for n in G:
    print(n)

def odd():
    print('Step 1')
    yield 1
    print('Step 2')
    yield 2
    print('Step 3')
    yield 3

gen = odd()     #如果直接调用odd（），则认为是每次用新的odd（）

print(next(gen))
print(next(gen))
print(next(gen))


import asyncio,sys,time

async def do():
    print('hello')
    time.sleep(2)

#@asyncio.coroutine
async def hello():
    print("Hello world!")
    # 异步调用asyncio.sleep(1):
    await asyncio.sleep(1)
    #await do()
    #do()
    print("Hello again!")

# 获取EventLoop:
loop = asyncio.get_event_loop()
# 执行coroutine
loop.run_until_complete(asyncio.wait([hello() for i in range(3)]))
loop.close()